<template>
  <!-- banner下导航部分 -->
  <div class="cate">
    <div
      v-for="(cate,index) in cateData"
      v-if="index<5"
      :key="index"
      class="cate_for_box"
    >
      <router-link
        class="cate-item"
        tag="div"
        :to="'/cate?id=' + cate.id"
        @mouseover.native="over(cate)"
        @mouseleave.native="leave(cate)"
      >
        <img
          :src="cate.isSelected ? cate.AdfullImageUrl : cate.fullImageUrl"
          alt=""
        >
        <span class="name">{{ cate.cName }}</span>
        <span class="button">点击选购</span>
      </router-link>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  components: {},
  data() {
    return {
      cateData: [],
    };
  },
 
  mounted() {
    this.getData(this.$route.query.id);
  },
  methods: {
    getData(shop_id) {
      let params = {
        shop_id:shop_id,
      }
      this.$api.commit.ShopCateGory(params).then((res) => {
        if (res.code == 1) {
          console.log('banner底部导航',res.data)
		  res.data.forEach(item=>{
			  if(item.status == 1){
				  this.cateData.push(item)
			  }
		  })
          //this.cateData= res.data
        }
      });
    },
    over(item) {
      console.log('over', item)
      item.isSelected = true;
    },
    leave(item) {
      console.log('leave', item)
      item.isSelected = false;
    },
  },
};
</script>

<style scoped lang="scss">
.cate {
  // width: 100%;
  padding: 0 16.19rem;
  // margin-top: 7.81rem;
  margin-top: 3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .cate_for_box:first-child{
    margin-left: 0;
  }
  .cate_for_box{
    margin-left: 1rem;
    .cate-item {
    width: 16rem;
    height: 17rem;
    background: rgba(255, 255, 255, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    img {
      width: 6.75rem;
      height: 4.88rem;
      object-fit: contain;
    }
    .name {
      font-size: 1.13rem;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: rgba(102, 102, 102, 1);
      margin-top: 1.13rem;
    }
    .button {
      width: 4.75rem;
      height: 1.44rem;
      background: rgba(0, 209, 169, 1);
      text-align: center;
      display: inline-block;
      margin-top: 0.94rem;
      line-height: 1.44rem;
      font-size: 0.88rem;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: rgba(255, 255, 255, 1);
    }
    &:hover {
      background: #00d1a9;
      .name {
        color: #ffffff;
      }
      .button {
        background: #ffffff;
        color: #00d1a9;
      }
    }
    }
  }
  
}
</style>
